setTimeout(function () {console.log(0)}, 0)

let promise = new Promise((resolve, reject) => {
     console.log(1)
     let status = true

     if (status) {
          resolve('success')
     } else {
          reject('failed')
     }
})
.then((data) => {console.log(data)}, (data) => {console.log(data)})

console.log(promise)

setTimeout( () => {
     console.log(promise)
}, 2500)

console.log(2)

function User (name, pass) {
     this.name = name
     this.pass = pass
}

User.prototype.showName = function () {
     console.log(this.name)
}

function VipUser (name, pass, level) {
     User.call(this, name, pass)
     this.level = level
}

VipUser.prototype = new User() //让 VipUser的prototype上继承User的方法
VipUser.prototype.constructor = VipUser // 修改prototype之后的congstrucotr

VipUser.prototype.showLevel = function () {
     console.log(this.level)
}

// es5中继承的思考？？？？

function inherit(Target,Origin) {//实现寄生组合式继承的核心函数
     function F() {};
     F.prototype = Origin.prototype; //F()的原型指向的是Origin
     Target.prototype = new F(); //Target的原型指向的是F()
     Target.prototype.constructor = Target; 
     SubType.prototype.__proto__ == SuperType.prototype
 }
 
 function SuperType(name) {
     this.name = name;
     this.colors = ['red','blue','pink'];
 }
 SuperType.prototype.sayName = function() {
     console.log(this.name);
 }
 function SubType(name,age) {
     //继承属性
     SuperType.call(this,name);//在创建实例时第二次调用SuperType
     this.age = age;
 }

// ES5 中的继承的另一种写法

 function Parent(){
     this.name = "parent";
     this.play = [1,2,3];
 }
 Parent.prototype.jsonArr = [{hi:123}]
 // 子类
 function Child(){
     Parent.call(this); // 构造函数继承
     this.type = "child";
 }
 
 Child.prototype = Object.create(Parent.prototype); 
 Child.prototype.constructor = Child;
 // 等价于下面这四句
 // var F = function(){};
 // F.prototype = Parent.prototype;
 // Child.prototype = new F();
 // Child.prototype.constructor = Child;
 
 
 var c1 = new Child();
 var c2 = new Child();
 console.log(c1.constructor);
 // 输出结果
 // ƒ Child(){
 //     Parent.call(this); // 构造函数继承
 //     this.type = "child";
 // }
